1.往集合中插入一个文档
db.users.insert(
{
	id:18,name:"xiaom",age:40
}
)
2.查询集合中所有文档
db.users.find(
{}
)
3.把一个带有name=xiaom的文档，修改其age值为30
db.users.update(
{name:"xiaom"},
{$set:{age:30}}
)
4.//修改所有name=dafei的文档，修改其name=bunny，age=20
db.users.updateMany(
{name:"dafei"},
{$set:{name:"bunny",age:20}}
)
5.修改所有的文档，修改其name=xxx，age=10
db.users.updateMany(
{},
{$set:{name:"xxx",age:10}}
)
6.添加一个sex的列
 db.users.update(
 {},
 {$set:{sex:""}},
 {multi:true}
 )
7.删除sex的列
db.users.update(
{},
{$unset:{sex:""}},
{multi:true}
)
8.//删除_id=5f25741b8d5700004400730a的文档
db.users.remove(
{_id:ObjectId("5f25741b8d5700004400730a")}
)
9.//删除所有带有name=dafei的文档
db.users.deleteMany(
{name:"dafei"}
)
10.//删除当前数据库中所有文档
db.users.deleteMany(
{}
)

db.users.insert({"id":NumberLong(1),"name":"dafei","age":NumberInt(18)})
db.users.insert({"id":NumberLong(2),"name":"xiaofei","age":NumberInt(20)})
db.users.insert({"id":NumberLong(3),"name":"zhang quan dan","age":NumberInt(33)})
db.users.insert({"id":NumberLong(4),"name":"zhang kun","age":NumberInt(26)})
db.users.insert({"id":NumberLong(6),"name":"cai xv kun","age":NumberInt(29)})
db.users.insert({"id":NumberLong(7),"name":"jia nai liang","age":NumberInt(25)})
db.users.insert({"id":NumberLong(8),"name":"fu rong wang","age":NumberInt(28)})
db.users.insert({"id":NumberLong(9),"name":"wang da","age":NumberInt(31)})
db.users.insert({"id":NumberLong(10),"name":"da wang","age":NumberInt(32)})
db.users.insert({"id":NumberLong(11),"name":"will","age":NumberInt(26)})

11.查所有用户
	db.users.find(
	{}
	)
12.查询所有用户按年龄排序(正序/倒序)
 db.users.find({}).sort({age:1})
 db.users.find({}).sort({age:-1})
13.查询所有用户按年龄和id排序(多列排序)
	db.users.find({}).sort({age:1,id:-1})
14.按照年龄降序排列，查询第2页，每页显示3个
	db.users.find({}).sort({age:-1}).skip(3).limit(3)
15.查询age > 30的用户
	db.users.find(
		{age:{$gt:30}}
	)
16.查询名字为 dafei 或xiaofei用户
db.users.find(
	{name:{$in:["dafei","xiaofei"]}}
)
17.判断判断指定name列是否存在
db.users.find(
{name:{$exists:true}}
)
18.查年龄在28 到 30间的用户信息
db.users.find(
{
	$and:[{age:{$gte:28}},{age:{$lte:30}}]
}
)

db.users.find(
{age:{$gte:28,$lte:30}}
)
19.查看年龄小于28或者年龄大于30用户信息
db.users.find(
{
	$or:[{age:{$lt:28}},{age:{$gt:30}}]
}
)
20.查看年龄等于28或者等于30用户信息
db.users.find(
{
	age:{$in:[28,30]}
}
)
21.查询name带有fei的用户信息
db.users.find(
{
	name:{$regex:"fei"}
}
)
22.查name中包含fei字样，并且年龄在28 到 30间的用户信息,
db.users.find(
{
	$and:[{name:/fei/},{age:{$gte:28,$lte:30}}]
}
)
数组操作 

23.给所有的数据添加数组字段hobby
db.users.updateMany(
{},
{$set:{habby:[]}}
)
24.给name等于dafei的用户添加java 爱好
db.users.update(
{name:"dafei"},
{$push:{habby:"java"}}
)
25给name=dafeide 数组habby字段添加数据， 不允许数据元素重复
db.users.update(
{name:"dafei"},
{$addToSet:{habby:"c"}}
)
26.给name等于dafei的用户添加'java', 'c', 'vue' 爱好
db.users.update(
{name:"dafei"},
{
$addToSet:{habby:{$each:["java","c","c++"]}}
},
{multi:true}
)
27.需求删除name=dafei用户最后一个兴趣
db.users.update(
{name:"dafei"},
{$pop:{habby:1}}
)
28.需求删除name=dafei用户第一个兴趣
db.users.update(
{name:"dafei"},
{$pop:{habby:-1}}
)
29.删除name=dafei用户java兴趣选项
db.users.update(
{name:"dafei"},
{$pull:{habby:"java"}}
)
30将name=dafei的用户索引为1的兴趣改为 go
db.users.update(
{name:"dafei"},
{$set:{"habby.1":"go"}}
)
31.将name=dafei的用户 c 兴趣 改为 c#
db.users.update(
{name:"dafei",habby:"c"},
{$set:{"habby.$":"c#"}}
)